
import React from 'react'
import  store from '../../store/store'
import {inCreatmentAction,deCreatmentAction,intimeoutAction} from '../../store/action/countaction'
import { useDispatch, useSelector } from 'react-redux/es/exports'
export default function Count() { 
  const dispatch = useDispatch()
  const count = useSelector((state)=>{
     return state.count.count
  })
    const inCreatmenthandle =()=>{
      
      dispatch(inCreatmentAction())
    }
    const deCreatmenthandle =()=>{
      dispatch(deCreatmentAction())
    }
    const inOddCreatmenthandle =()=>{
        if(count % 2 != 0){
          dispatch(inCreatmentAction())
        }
    }
    const inTimeouthandle =(data)=>{
        
          dispatch(intimeoutAction())
        
    }
  return (
    <div>
        <h1>我是Count组件 我的数量是{count}</h1>
        <button onClick={inCreatmenthandle}>累加</button>
        <button onClick={deCreatmenthandle}>累减</button>
        <button onClick={inOddCreatmenthandle}>基数添加</button>
        <button onClick={inTimeouthandle}>延迟添加</button>
    </div>
  )
}
